package org.xw.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xw.dto.MsgDTO;
import org.xw.service.MessageService;
import org.xw.utils.ResponseUtil;

@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    MessageService messageService;

    /**
     * "分页"查询聊天记录
     *
     * @param httpServletRequest
     * @param msgDTO
     * @return
     */
    @PostMapping("")
    public ResponseUtil getMsg(HttpServletRequest httpServletRequest,@RequestBody MsgDTO msgDTO) {
        return messageService.getMsg(httpServletRequest, msgDTO);
    }

    /**
     * 条件查询聊天记录，日期，内容，成员
     *
     * @param msgDTO
     * @return
     */
    @PostMapping("/select")
    public ResponseUtil selectMsg(@RequestBody MsgDTO msgDTO) {
        return messageService.selectMsg(msgDTO);
    }


}
